<?php
class Admin_NurseController extends Ctrl_Admin{
    public function indexAction(){
        $p = $_REQUEST;
        $pName = empty($p['name'])?'':Tool_Fnc::safe_string($p['name']);
        $pCreated = empty($p['created'])?'':Tool_Fnc::safe_string($p['created']);
        $pDepartment = empty($p['department'])?'':Tool_Fnc::safe_string($p['department']);
 
        $tTime = time();        

        $tSMO = new SeniorModel;
        $tDIMO = new DepartmentinfoModel;
        $tBSMO = new Blood_SugarModel;
        $tBMO = new BodytemperatureModel;
        $tBPMO = new Blood_PressureModel;
        $tMMO = new MoodModel;
        $tSkMO = new SkinModel;
        $tAMO = new AdminModel;
        $tWMO = new WorkerModel;

        $tWhere = ' 1 and s.leave_status = 2';

        if(!empty($_COOKIE['admin']['roles'])){
            if($_COOKIE['admin']['roles'] != 1 && $_COOKIE['admin']['roles'] != 2){//管理员之外
                $tSql = 'select w.department department from '.$tAMO->table.' a left join '.$tWMO->table.' w on w.id = a.w_id where a.id = '.$_SESSION['admin']['id'];
                $tAData = $tAMO->query($tSql);
                $tWhere = ' 1 and s.leave_status = 2 and s.department = '.$tAData[0]['department'];
            }
        }

        if(!empty($pName)){
            $tWhere .= ' and s.name like \'%'.$pName.'%\'';
        }
        if(!empty($pCreated)){
            $tWhere .= ' and FROM_UNIXTIME(s.created,\'%Y-%m-%d\') = \''.$pCreated.'\'';
        }
        if(!empty($pDepartment)){
            $tWhere .= ' and s.department = '.$pDepartment;
        }

        //$tCount = $tSMO->field('count(*) c')->where($tWhere)->fList();
        $tSql = 'select count(*) c from '.$tSMO->table.' s left join '.$tDIMO->table.' di on s.department = di.num where '.$tWhere;
        $tCount = $tSMO->query($tSql);
        $tCnt = empty($tCount[0]['c'])?0:$tCount[0]['c'];
        $tLimit = 10;
        $tPage = new Tool_Page($tCnt,$tLimit);
        if(!empty($tCnt)){
            //查询老人信息
            $tSql = 'select s.id id,s.name name,di.introduce department,s.created created from '.$tSMO->table.' s left join '.$tDIMO->table.' di on s.department = di.num where '.$tWhere.' order by s.id desc limit '.$tPage->limit();
            $tSDatas = $tSMO->query($tSql);
            if(!empty($tSDatas)){
            foreach($tSDatas as $tSKey => $tSRow){
                //查询今日血糖信息
                $tBSData = $tBSMO->field('blood_sugar')->where('sid = '.$tSRow['id'].' and date = \''.date('Y-m-d',$tTime).'\'')->fRow();
                $tSDatas[$tSKey]['blood_sugar'] = empty($tBSData['blood_sugar'])?'':$tBSData['blood_sugar'];
                //查询今日体温信息
                $tBData = $tBMO->field('temperature')->where('sid = '.$tSRow['id'].' and date = \''.date('Y-m-d',$tTime).'\'')->fRow();
                $tSDatas[$tSKey]['temperature'] = empty($tBData['temperature'])?'':$tBData['temperature'];
                //查询今日血压信息
                $tBPData = $tBPMO->field('high_pressure,low_pressure')->where('sid = '.$tSRow['id'].' and date = \''.date('Y-m-d',$tTime).'\'')->fRow();
                $tSDatas[$tSKey]['high_pressure'] = empty($tBPData['high_pressure'])?'':$tBPData['high_pressure'];
                $tSDatas[$tSKey]['low_pressure'] = empty($tBPData['low_pressure'])?'':$tBPData['low_pressure'];
                //查询今日精神状态信息
                $tMData = $tMMO->field('status mood_status')->where('sid = '.$tSRow['id'].' and date = \''.date('Y-m-d',$tTime).'\'')->fRow();
                $tSDatas[$tSKey]['mood_status'] = empty($tMData['mood_status'])?'':$tMData['mood_status'];
                //查询今日皮肤状态信息
                $tSkData = $tSkMO->field('skin_status')->where('sid = '.$tSRow['id'].' and date = \''.date('Y-m-d',$tTime).'\'')->fRow();
                $tSDatas[$tSKey]['skin_status'] = empty($tSkData['skin_status'])?'':$tSkData['skin_status'];
            }
            }
            $tDatas = $tSMO->query($tSql);
        } 

        //所在部门显示
        $tDIData = $tDIMO->field('num,introduce')->fList();

        $this->assign('tDIData',$tDIData);
        $this->assign('tSDatas',$tSDatas);
        $this->assign('pName',$pName);
        $this->assign('pCreated',$pCreated);
        $this->assign('pDepartment',$pDepartment);
        $this->assign('tShow',$tPage->show());
    }
    public function detailAction(){
        $p = $_REQUEST;
        $pId = empty($p['sid'])?Tool_Fnc::ajaxMsg('ID不能为空'):Tool_Fnc::safe_string($p['sid']);

        $tTime = time();
        
        $tSMO = new SeniorModel;
        $tDIMO = new DepartmentinfoModel;
        $tBSMO = new Blood_SugarModel;
        $tBMO = new BodytemperatureModel;
        $tBPMO = new Blood_PressureModel;
        $tMMO = new MoodModel;
        $tSkMO = new SkinModel;
        $tNMO = new NursingModel;
        $tEMO = new EatingModel;
        $tMeMO = new MedicineModel;
        $tMelMO = new MedicinelibraryModel;

        $tSexData = array();
        $tFiveData = array();
        $tFourData = array();
        $tThreeData = array();
        $tTwoData = array();
        $tOneData = array();
        $tData = array();

        //查询六日前早上所有护理信息
        #血压
        $tBPData = $tBPMO->field('high_pressure,low_pressure')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        $tSexData['high_pressure'] = empty($tBPData['high_pressure'])?'':$tBPData['high_pressure'];
        $tSexData['low_pressure'] = empty($tBPData['low_pressure'])?'':$tBPData['low_pressure'];
        #血糖
        $tBSData = $tBSMO->field('blood_sugar')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        $tSexData['blood_sugar'] = empty($tBSData['blood_sugar'])?'':$tBSData['blood_sugar'];
        #体温
        $tBData = $tBMO->field('temperature')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        $tSexData['temperature'] = empty($tBData['temperature'])?'':$tBData['temperature'];
        #精神状态
        $tMData = $tMMO->field('status mood_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        $tSexData['mood_status'] = empty($tMData['mood_status'])?'':$tMData['mood_status'];
        #褥疮状态
        $tSkData = $tSkMO->field('skin_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        $tSexData['skin_status'] = empty($tSkData['skin_status'])?'':$tSkData['skin_status'];
        #洗漱
        $tNData = $tNMO->field('type nursing_type')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        if(!empty($tNData)){
        $tNData = explode(',',$tNData['nursing_type']);
        foreach($tNData as $tKey=>$tValue){
            if($tValue == 1){
                $tNData[$tKey] = '洗脸';
            }else if($tValue == 2){
                $tNData[$tKey] = '假牙清洗';
            }else if($tValue == 3){
                $tNData[$tKey] = '口腔护理';
            }
        }
        }
        $tSexData['nursing_type'] = implode(',',$tNData);
        #用饭
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 1')->fRow();
        $tSexData['appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-6 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        if(!empty($tMeData1)){
            $tStr1 = '';
            foreach($tMeData1 as $tK=>$tV){
                $tStr1 .= $tMeData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStr1)){$tStr1 = trim($tStr1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-6 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        if(!empty($tMeData2)){
            $tStr2 = '';
            foreach($tMeData2 as $tK=>$tV){
                $tStr2 .= $tMeData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStr2)){$tStr2 = trim($tStr2,',');}
        $tSexData['medicine_yi'] = empty($tStr1)?'':$tStr1;
        $tSexData['medicine_jj'] = empty($tStr2)?'':$tStr2;
        
        #喝水
        $tDMO = new DrikingModel;
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fList()[0];
        $tSexData['driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tSexData['driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #大便小便
        $tExMO = new ExcretionModel;
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow(); 
        $tSexData['small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tSexData['big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];

        //查询六日前上午所有护理信息
        #加餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 2')->fRow();
        $tSexData['sw_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow(); 
        $tSexData['swsmall_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tSexData['swbig_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        #仪表
        $tAMO = new AppearanceModel;
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tSexData['sw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMMO = new BedmanagementModel;
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        $tSexData['pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tSexData['pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tSexData['pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tSexData['sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tSexData['mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tSexData['quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tSexData['quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #康复干预
        $tRIMO = new RehabilitationinterventionModel;
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 1')->fList();
        $tSexData['hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 2')->fList();
        $tSexData['kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 3')->fList();
        $tSexData['sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 4')->fList();
        $tSexData['sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCMO = new WashclothModel;
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        if(!empty($tWCDatas)){
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tSexData['underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tSexData['coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #探视
        $tVMO = new VisitModel;
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tSexData['friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tSexData['relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];

        //查询六日前中午所有护理信息
        //胰岛素
        $tIlMO = new InsulinModel;
        $tIlData = $tIlMO->field('id')->where('sid  = '.$pId.' and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and at = 3')->fRow();
        $tSexData['insulin'] = empty($tIlData['id'])?'':'是';
        //用饭
        $tEwData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 1')->fRow();
        $tSexData['zw_appetite'] = empty($tEwData['appetite'])?'':$tEwData['appetite'];
        //用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-6 days')).'\' and m.status = 1';
        $tMezData1 = $tMeMO->query($tSql);
        if(!empty($tMezData1)){
            $tStrz1 = '';
            foreach($tMezData1 as $tK=>$tV){
                $tStrz1 .= $tMezData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrz1)){$tStrz1 = trim($tStrz1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-6 days')).'\' and m.status = 2';
        $tMezData2 = $tMeMO->query($tSql);
        if(!empty($tMezData2)){
            $tStrz2 = '';
            foreach($tMezData2 as $tK=>$tV){
                $tStrz2 .= $tMezData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrz2)){$tStrz2 = trim($tStrz2,',');}
        $tSexData['zw_medicine_yi'] = empty($tStrz1)?'':$tStrz1;
        $tSexData['zw_medicine_jj'] = empty($tStrz2)?'':$tStrz2;
        #午睡
        $tSTMO = new SiestaModel;
        $tSTData = $tSTMO->field('duration')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        $tSexData['siesta'] = empty($tSTData['duration'])?'':$tSTData['duration']; 
        //查询六日前下午所有护理信息
        #加餐
        $tEjData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 2')->fRow();
        $tSexData['xw_appetite'] = empty($tEjData['appetite'])?'':$tEjData['appetite'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        $tAData = explode(',',$tAData['type']);
        if(!empty($tAData)){
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tSexData['xw_appearance'] = empty($tAData)?'':implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        $tSexData['xw_pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tSexData['xw_pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tSexData['xw_pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tSexData['xw_sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tSexData['xw_mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tSexData['xw_quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tSexData['xw_quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tSexData['xw_friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tSexData['xw_relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];
        
        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 1')->fList();
        $tSexData['xw_hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 2')->fList();
        $tSexData['xw_kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 3')->fList();
        $tSexData['xw_sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 4')->fList();
        $tSexData['xw_sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        if(!empty($tWCDatas)){
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tSexData['xw_underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tSexData['xw_coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow(); 
        $tSexData['xw_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tSexData['xw_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询六日前晚上所有护理信息
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fList()[0];
        $tSexData['ws_driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tSexData['ws_driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #晚餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-6 days')).'\' and type = 1')->fRow();
        $tSexData['ws_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-6 days')).'\' and m.status = 1';
        $tMewData1 = $tMeMO->query($tSql);
        if(!empty($tMewData1)){
            $tStrw1 = '';
            foreach($tMewData1 as $tK=>$tV){
                $tStrw1 .= $tMewData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrw1)){$tStrw1 = trim($tStrw1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-6 days')).'\' and m.status = 2';
        $tMewData2 = $tMeMO->query($tSql);
        if(!empty($tMewDataw2)){
            $tStrw2 = '';
            foreach($tMewData2 as $tK=>$tV){
                $tStrw2 .= $tMewData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrw2)){$tStrw2 = trim($tStrw2,',');}
        $tSexData['ws_medicine_yi'] = empty($tStrw1)?'':$tStrw1;
        $tSexData['ws_medicine_jj'] = empty($tStrw2)?'':$tStrw2;
        #夜间睡眠
        $tSlMO = new SleepModel;
        $tSlData = $tSlMO->field('status,count')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow();
        if(!empty($tSlData)){
            foreach($tSlData as $tK=>$tV){
                switch($SlData[$tK]){
                    case 1:$tSlData[$tK] = '正常';break;
                    case 2:$tSlData[$tK] = '暴动';break;
                    case 3:$tSlData[$tK] = '无睡意';break;
                }
            }
        }
        $tSexData['sleep_status'] = empty($tSlData['status'])?'':$tSlData['status'];
        $tSexData['sleep_count'] = empty($tSlData['count'])?'':$tSlData['count'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-6 days')).'\'')->fRow(); 
        $tSexData['wssmall_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tSexData['wsbig_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];

        //查询五日前早上所有护理信息
        #血压
        $tBPData = $tBPMO->field('high_pressure,low_pressure')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        $tFiveData['high_pressure'] = empty($tBPData['high_pressure'])?'':$tBPData['high_pressure'];
        $tFiveData['low_pressure'] = empty($tBPData['low_pressure'])?'':$tBPData['low_pressure'];
        #血糖
        $tBSData = $tBSMO->field('blood_sugar')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        $tFiveData['blood_sugar'] = empty($tBSData['blood_sugar'])?'':$tBSData['blood_sugar'];
        #体温
        $tBData = $tBMO->field('temperature')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        $tFiveData['temperature'] = empty($tBData['temperature'])?'':$tBData['temperature'];
        #精神状态
        $tMData = $tMMO->field('status mood_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        $tFiveData['mood_status'] = empty($tMData['mood_status'])?'':$tMData['mood_status'];
        #褥疮状态
        $tSkData = $tSkMO->field('skin_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        $tFiveData['skin_status'] = empty($tSkData['skin_status'])?'':$tSkData['skin_status'];
        #洗漱
        $tNData = $tNMO->field('type nursing_type')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        $tNData = explode(',',$tNData['nursing_type']);
        if(!empty($tNData)){
        foreach($tNData as $tKey=>$tValue){
            if($tValue == 1){
                $tNData[$tKey] = '洗脸';
            }else if($tValue == 2){
                $tNData[$tKey] = '假牙清洗';
            }else if($tValue == 3){
                $tNData[$tKey] = '口腔护理';
            }
        }
        }
        $tFiveData['nursing_type'] = implode(',',$tNData);
        #用饭
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 1')->fRow();
        $tFiveData['appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-5 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        if(!empty($tMeData1)){
            $tStr1 = '';
            foreach($tMeData1 as $tK=>$tV){
                $tStr1 .= $tMeData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStr1)){$tStr1 = trim($tStr1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-5 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        if(!empty($tMeData2)){
            $tStr2 = '';
            foreach($tMeData2 as $tK=>$tV){
                $tStr2 .= $tMeData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStr2)){$tStr2 = trim($tStr2,',');}
        $tFiveData['medicine_yi'] = empty($tStr1)?'':$tStr1;
        $tFiveData['medicine_jj'] = empty($tStr2)?'':$tStr2;
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fList()[0];
        $tFiveData['driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tFiveData['driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow(); 
        $tFiveData['small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tFiveData['big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询五日前上午所有护理信息
        #加餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 2')->fRow();
        $tFiveData['sw_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow(); 
        $tFiveData['swsmall_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tFiveData['swbig_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        $tAData = explode(',',$tAData['type']);
        if(!empty($tAData)){
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tFiveData['sw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        $tFiveData['pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tFiveData['pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tFiveData['pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tFiveData['sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tFiveData['mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tFiveData['quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tFiveData['quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 1')->fList();
        $tFiveData['hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 2')->fList();
        $tFiveData['kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 3')->fList();
        $tFiveData['sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 4')->fList();
        $tFiveData['sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCMO = new WashclothModel;
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        if(!empty($tWCDatas)){
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tFiveData['underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tFiveData['coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tFiveData['friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tFiveData['relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];

        //查询五日前中午所有护理信息
        //胰岛素
        $tIlMO = new InsulinModel;
        $tIlData = $tIlMO->field('id')->where('sid  = '.$pId.' and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and at = 3')->fRow();
        $tFiveData['insulin'] = empty($tIlData['id'])?'':'是';
        //用饭
        $tEwData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 1')->fRow();
        $tFiveData['zw_appetite'] = empty($tEwData['appetite'])?'':$tEwData['appetite'];
        //用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-5 days')).'\' and m.status = 1';
        $tMezData1 = $tMeMO->query($tSql);
        if(!empty($tMezData1)){
            $tStrz1 = '';
            foreach($tMezData1 as $tK=>$tV){
                $tStrz1 .= $tMezData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrz1)){$tStrz1 = trim($tStrz1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-5 days')).'\' and m.status = 2';
        $tMezData2 = $tMeMO->query($tSql);
        if(!empty($tMezData2)){
            $tStrz2 = '';
            foreach($tMezData2 as $tK=>$tV){
                $tStrz2 .= $tMezData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrz2)){$tStrz2 = trim($tStrz2,',');}
        $tFiveData['zw_medicine_yi'] = empty($tStrz1)?'':$tStrz1;
        $tFiveData['zw_medicine_jj'] = empty($tStrz2)?'':$tStrz2;
        #午睡
        $tSTMO = new SiestaModel;
        $tSTData = $tSTMO->field('duration')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        $tFiveData['siesta'] = empty($tSTData['duration'])?'':$tSTData['duration']; 
        //查询五日前下午所有护理信息
        #加餐
        $tEjData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 2')->fRow();
        $tFiveData['xw_appetite'] = empty($tEjData['appetite'])?'':$tEjData['appetite'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tFiveData['xw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        $tFiveData['xw_pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tFiveData['xw_pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tFiveData['xw_pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tFiveData['xw_sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tFiveData['xw_mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tFiveData['xw_quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tFiveData['xw_quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tFiveData['xw_friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tFiveData['xw_relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];

        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 1')->fList();
        $tFiveData['xw_hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 2')->fList();
        $tFiveData['xw_kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 3')->fList();
        $tFiveData['xw_sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 4')->fList();
        $tFiveData['xw_sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        if(!empty($tWCDatas)){
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tFiveData['xw_underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tFiveData['xw_coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow(); 
        $tFiveData['xw_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tFiveData['xw_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询五日前晚上所有护理信息
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fList()[0];
        $tFiveData['ws_driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tFiveData['ws_driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #晚餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-5 days')).'\' and type = 1')->fRow();
        $tFiveData['ws_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-5 days')).'\' and m.status = 1';
        $tMewData1 = $tMeMO->query($tSql);
        if(!empty($tMeDataw1)){
            $tStrw1 = '';
            foreach($tMewData1 as $tK=>$tV){
                $tStrw1 .= $tMewData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrw1)){$tStrw1 = trim($tStrw1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-5 days')).'\' and m.status = 2';
        $tMewData2 = $tMeMO->query($tSql);
        if(!empty($tMeDataw2)){
            $tStrw2 = '';
            foreach($tMewData2 as $tK=>$tV){
                $tStrw2 .= $tMewData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrw2)){$tStrw2 = trim($tStrw2,',');}
        $tFiveData['ws_medicine_yi'] = empty($tStrw1)?'':$tStrw1;
        $tFiveData['ws_medicine_jj'] = empty($tStrw2)?'':$tStrw2;
        #夜间睡眠
        $tSlMO = new SleepModel;
        $tSlData = $tSlMO->field('status,count')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow();
        if(!empty($tSlData)){
            foreach($tSlData as $tK=>$tV){
                switch($SlData[$tK]){
                    case 1:$tSlData[$tK] = '正常';break;
                    case 2:$tSlData[$tK] = '暴动';break;
                    case 3:$tSlData[$tK] = '无睡意';break;
                }
            }
        }
        $tFiveData['sleep_status'] = empty($tSlData['status'])?'':$tSlData['status'];
        $tFiveData['sleep_count'] = empty($tSlData['count'])?'':$tSlData['count'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-5 days')).'\'')->fRow(); 
        $tFiveData['ws_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tFiveData['ws_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];

        //查询四日前早上所有护理信息
        #血压
        $tBPData = $tBPMO->field('high_pressure,low_pressure')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        $tFourData['high_pressure'] = empty($tBPData['high_pressure'])?'':$tFourData['high_pressure'];
        $tFourData['low_pressure'] = empty($tBPData['low_pressure'])?'':$tBPData['low_pressure'];
        #血糖
        $tBSData = $tBSMO->field('blood_sugar')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        $tFourData['blood_sugar'] = empty($tBSData['blood_sugar'])?'':$tBSData['blood_sugar'];
        #体温
        $tBData = $tBMO->field('temperature')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        $tFourData['temperature'] = empty($tBData['temperature'])?'':$tBData['temperature'];
        #精神状态
        $tMData = $tMMO->field('status mood_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        $tFourData['mood_status'] = empty($tMData['mood_status'])?'':$tMData['mood_status'];
        #褥疮状态
        $tSkData = $tSkMO->field('skin_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        $tFourData['skin_status'] = empty($tSkData['skin_status'])?'':$tSkData['skin_status'];
        #洗漱
        $tNData = $tNMO->field('type nursing_type')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        $tNData = explode(',',$tNData['nursing_type']);
        if(!empty($tNData)){
        foreach($tNData as $tKey=>$tValue){
            if($tValue == 1){
                $tNData[$tKey] = '洗脸';
            }else if($tValue == 2){
                $tNData[$tKey] = '假牙清洗';
            }else if($tValue == 3){
                $tNData[$tKey] = '口腔护理';
            }
        }
        }
        $tFourData['nursing_type'] = implode(',',$tNData);
        #用饭
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 1')->fRow();
        $tFourData['appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-4 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        if(!empty($tMeData1)){
            $tStr1 = '';
            foreach($tMeData1 as $tK=>$tV){
                $tStr1 .= $tMeData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStr1)){$tStr1 = trim($tStr1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-4 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        if(!empty($tMeData2)){
            $tStr2 = '';
            foreach($tMeData2 as $tK=>$tV){
                $tStr2 .= $tMeData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStr2)){$tStr2 = trim($tStr2,',');}
        $tFourData['medicine_yi'] = empty($tStr1)?'':$tStr1;
        $tFourData['medicine_jj'] = empty($tStr2)?'':$tStr2;
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fList()[0];
        $tFourData['driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tFourData['driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow(); 
        $tFourData['small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tFourData['big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询四日前上午所有护理信息
        #加餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 2')->fRow();
        $tFourData['sw_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow(); 
        $tFourData['swsmall_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tFourData['swbig_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tFourData['sw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        $tFourData['pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tFourData['pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tFourData['pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tFourData['sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tFourData['mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tFourData['quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tFourData['quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 1')->fList();
        $tFourData['hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 2')->fList();
        $tFourData['kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 3')->fList();
        $tFourData['sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 4')->fList();
        $tFourData['sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        if(!empty($tWCDatas)){
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tFourData['underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tFourData['coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tFourData['friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tFourData['relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];

        //查询四日前中午所有护理信息
        //胰岛素
        $tIlMO = new InsulinModel;
        $tIlData = $tIlMO->field('id')->where('sid  = '.$pId.' and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and at = 3')->fRow();
        $tFourData['insulin'] = empty($tIlData['id'])?'':'是';
        //用饭
        $tEwData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 1')->fRow();
        $tFourData['zw_appetite'] = empty($tEwData['appetite'])?'':$tEwData['appetite'];
        //用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-4 days')).'\' and m.status = 1';
        $tMezData1 = $tMeMO->query($tSql);
        if(!empty($tMezData1)){
            $tStrz1 = '';
            foreach($tMezData1 as $tK=>$tV){
                $tStrz1 .= $tMezData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrz1)){$tStrz1 = trim($tStrz1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-4 days')).'\' and m.status = 2';
        $tMezData2 = $tMeMO->query($tSql);
        if(!empty($tMezData2)){
            $tStrz2 = '';
            foreach($tMezData2 as $tK=>$tV){
                $tStrz2 .= $tMezData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrz2)){$tStrz2 = trim($tStrz2,',');}
        $tFourData['zw_medicine_yi'] = empty($tStrz1)?'':$tStrz1;
        $tFourData['zw_medicine_jj'] = empty($tStrz2)?'':$tStrz2;
        #午睡
        $tSTMO = new SiestaModel;
        $tSTData = $tSTMO->field('duration')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        $tFourData['siesta'] = empty($tSTData['duration'])?'':$tSTData['duration']; 
        //查询四日前下午所有护理信息
        #加餐
        $tEjData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 2')->fRow();
        $tFourData['xw_appetite'] = empty($tEjData['appetite'])?'':$tEjData['appetite'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tFourData['xw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        $tFourData['xw_pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tFourData['xw_pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tFourData['xw_pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tFourData['xw_sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tFourData['xw_mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tFourData['xw_quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tFourData['xw_quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tFourData['xw_friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tFourData['xw_relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];

        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 1')->fList();
        $tFourData['xw_hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 2')->fList();
        $tFourData['xw_kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 3')->fList();
        $tFourData['xw_sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 4')->fList();
        $tFourData['xw_sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        if(!empty($tWCDatas)){
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tFourData['xw_underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tFourData['xw_coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow(); 
        $tFourData['xw_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tFourData['xw_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询四日前晚上所有护理信息
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fList()[0];
        $tFourData['ws_driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tFourData['ws_driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #晚餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-4 days')).'\' and type = 1')->fRow();
        $tFourData['ws_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-4 days')).'\' and m.status = 1';
        $tMewData1 = $tMeMO->query($tSql);
        if(!empty($tMewData1)){
            $tStrw1 = '';
            foreach($tMewData1 as $tK=>$tV){
                $tStrw1 .= $tMewData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrw1)){$tStrw1 = trim($tStrw1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-4 days')).'\' and m.status = 2';
        $tMewData2 = $tMeMO->query($tSql);
        if(!empty($tMeDataww)){
            $tStrww = '';
            foreach($tMewDataw as $tK=>$tV){
                $tStrw2 .= $tMewData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrw2)){$tStrw2 = trim($tStrw2,',');}
        $tFourData['ws_medicine_yi'] = empty($tStrw1)?'':$tStrw1;
        $tFourData['ws_medicine_jj'] = empty($tStrw2)?'':$tStrw2;
        #夜间睡眠
        $tSlMO = new SleepModel;
        $tSlData = $tSlMO->field('status,count')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow();
        if(!empty($tSlData)){
            foreach($tSlData as $tK=>$tV){
                switch($SlData[$tK]){
                    case 1:$tSlData[$tK] = '正常';break;
                    case 2:$tSlData[$tK] = '暴动';break;
                    case 3:$tSlData[$tK] = '无睡意';break;
                }
            }
        }
        $tFourData['sleep_status'] = empty($tSlData['status'])?'':$tSlData['status'];
        $tFourData['sleep_count'] = empty($tSlData['count'])?'':$tSlData['count'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-4 days')).'\'')->fRow(); 
        $tFourData['ws_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tFourData['ws_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];

        //查询三日前早上所有护理信息
        #血压
        $tBPData = $tBPMO->field('high_pressure,low_pressure')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        $tThreeData['high_pressure'] = empty($tBPData['high_pressure'])?'':$tBPData['high_pressure'];
        $tThreeData['low_pressure'] = empty($tBPData['low_pressure'])?'':$tBPData['low_pressure'];
        #血糖
        $tBSData = $tBSMO->field('blood_sugar')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        $tThreeData['blood_sugar'] = empty($tBSData['blood_sugar'])?'':$tBSData['blood_sugar'];
        #体温
        $tBData = $tBMO->field('temperature')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        $tThreeData['temperature'] = empty($tBData['temperature'])?'':$tBData['temperature'];
        #精神状态
        $tMData = $tMMO->field('status mood_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        $tThreeData['mood_status'] = empty($tMData['mood_status'])?'':$tMData['mood_status'];
        #褥疮状态
        $tSkData = $tSkMO->field('skin_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        $tThreeData['skin_status'] = empty($tSkData['skin_status'])?'':$tSkData['skin_status'];
        #洗漱
        $tNData = $tNMO->field('type nursing_type')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        if(!empty($tNData)){
        $tNData = explode(',',$tNData['nursing_type']);
        foreach($tNData as $tKey=>$tValue){
            if($tValue == 1){
                $tNData[$tKey] = '洗脸';
            }else if($tValue == 2){
                $tNData[$tKey] = '假牙清洗';
            }else if($tValue == 3){
                $tNData[$tKey] = '口腔护理';
            }
        }
        }
        $tThreeData['nursing_type'] = implode(',',$tNData);
        #用饭
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 1')->fRow();
        $tThreeData['appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-3 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        if(!empty($tMeData1)){
            $tStr1 = '';
            foreach($tMeData1 as $tK=>$tV){
                $tStr1 .= $tMeData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStr1)){$tStr1 = trim($tStr1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-3 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        if(!empty($tMeData2)){
            $tStr2 = '';
            foreach($tMeData2 as $tK=>$tV){
                $tStr2 .= $tMeData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStr2)){$tStr2 = trim($tStr2,',');}
        $tThreeData['medicine_yi'] = empty($tStr1)?'':$tStr1;
        $tThreeData['medicine_jj'] = empty($tStr2)?'':$tStr2;
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fList()[0];
        $tThreeData['driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tThreeData['driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow(); 
        $tThreeData['small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tThreeData['big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询三日前上午所有护理信息
        #加餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 2')->fRow();
        $tThreeData['sw_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow(); 
        $tThreeData['swsmall_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tThreeData['swbig_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tThreeData['sw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        $tThreeData['pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tThreeData['pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tThreeData['pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tThreeData['sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tThreeData['mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tThreeData['quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tThreeData['quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 1')->fList();
        $tThreeData['hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 2')->fList();
        $tThreeData['kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 3')->fList();
        $tThreeData['sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 4')->fList();
        $tThreeData['sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        if(!empty($tWCDatas)){
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tThreeData['underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tThreeData['coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tThreeData['friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tThreeData['relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];

        //查询三日前中午所有护理信息
        //胰岛素
        $tIlMO = new InsulinModel;
        $tIlData = $tIlMO->field('id')->where('sid  = '.$pId.' and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and at = 3')->fRow();
        $tThreeData['insulin'] = empty($tIlData['id'])?'':'是';
        //用饭
        $tEwData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 1')->fRow();
        $tThreeData['zw_appetite'] = empty($tEwData['appetite'])?'':$tEwData['appetite'];
        //用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-3 days')).'\' and m.status = 1';
        $tMezData1 = $tMeMO->query($tSql);
        if(!empty($tMezData1)){
            $tStrz1 = '';
            foreach($tMezData1 as $tK=>$tV){
                $tStrz1 .= $tMezData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrz1)){$tStrz1 = trim($tStrz1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-3 days')).'\' and m.status = 2';
        $tMezData2 = $tMeMO->query($tSql);
        if(!empty($tMeDataz2)){
            $tStrz2 = '';
            foreach($tMezData2 as $tK=>$tV){
                $tStrz2 .= $tMezData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrz2)){$tStrz2 = trim($tStrz2,',');}
        $tThreeData['zw_medicine_yi'] = empty($tStrz1)?'':$tStrz1;
        $tThreeData['zw_medicine_jj'] = empty($tStrz2)?'':$tStrz2;
        #午睡
        $tSTMO = new SiestaModel;
        $tSTData = $tSTMO->field('duration')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        $tThreeData['siesta'] = empty($tSTData['duration'])?'':$tSTData['duration']; 
        //查询三日前下午所有护理信息
        #加餐
        $tEjData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 2')->fRow();
        $tThreeData['xw_appetite'] = empty($tEjData['appetite'])?'':$tEjData['appetite'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tThreeData['xw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        $tThreeData['xw_pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tThreeData['xw_pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tThreeData['xw_pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tThreeData['xw_sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tThreeData['xw_mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tThreeData['xw_quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tThreeData['xw_quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tThreeData['xw_friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tThreeData['xw_relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];
        
        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 1')->fList();
        $tThreeData['xw_hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 2')->fList();
        $tThreeData['xw_kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 3')->fList();
        $tThreeData['xw_sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 4')->fList();
        $tThreeData['xw_sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        if(!empty($tWCDatas)){
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tThreeData['xw_underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tThreeData['xw_coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow(); 
        $tThreeData['xw_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tThreeData['xw_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询三日前晚上所有护理信息
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fList()[0];
        $tThreeData['ws_driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tThreeData['ws_driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #晚餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-3 days')).'\' and type = 1')->fRow();
        $tThreeData['ws_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-3 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-3 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        $tThreeData['ws_medicine_yi'] = empty($tMeData1[0])?'':$tMeData1[0];
        $tThreeData['ws_medicine_jj'] = empty($tMeData2[0])?'':$tMeData2[0];
        #夜间睡眠
        $tSlMO = new SleepModel;
        $tSlData = $tSlMO->field('status,count')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow();
        if(!empty($tSlData)){
            foreach($tSlData as $tK=>$tV){
                switch($SlData[$tK]){
                    case 1:$tSlData[$tK] = '正常';break;
                    case 2:$tSlData[$tK] = '暴动';break;
                    case 3:$tSlData[$tK] = '无睡意';break;
                }
            }
        }
        $tThreeData['sleep_status'] = empty($tSlData['status'])?'':$tSlData['status'];
        $tThreeData['sleep_count'] = empty($tSlData['count'])?'':$tSlData['count'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-3 days')).'\'')->fRow(); 
        $tThreeData['ws_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tThreeData['ws_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];

        //查询两日前早上所有护理信息
        #血压
        $tBPData = $tBPMO->field('high_pressure,low_pressure')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        $tTwoData['high_pressure'] = empty($tBPData['high_pressure'])?'':$tBPData['high_pressure'];
        $tTwoData['low_pressure'] = empty($tBPData['low_pressure'])?'':$tBPData['low_pressure'];
        #血糖
        $tBSData = $tBSMO->field('blood_sugar')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        $tTwoData['blood_sugar'] = empty($tBSData['blood_sugar'])?'':$tBSData['blood_sugar'];
        #体温
        $tBData = $tBMO->field('temperature')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        $tTwoData['temperature'] = empty($tBData['temperature'])?'':$tBData['temperature'];
        #精神状态
        $tMData = $tMMO->field('status mood_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        $tTwoData['mood_status'] = empty($tMData['mood_status'])?'':$tMData['mood_status'];
        #褥疮状态
        $tSkData = $tSkMO->field('skin_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        $tTwoData['skin_status'] = empty($tSkData['skin_status'])?'':$tSkData['skin_status'];
        #洗漱
        $tNData = $tNMO->field('type nursing_type')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        if(!empty($tNData)){
        $tNData = explode(',',$tNData['nursing_type']);
        foreach($tNData as $tKey=>$tValue){
            if($tValue == 1){
                $tNData[$tKey] = '洗脸';
            }else if($tValue == 2){
                $tNData[$tKey] = '假牙清洗';
            }else if($tValue == 3){
                $tNData[$tKey] = '口腔护理';
            }
        }
        }
        $tTwoData['nursing_type'] = implode(',',$tNData);
        #用饭
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 1')->fRow();
        $tTwoData['appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-2 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-2 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        $tTwoData['medicine_yi'] = empty($tMeData1[0])?'':$tMeData1[0];
        $tTwoData['medicine_jj'] = empty($tMeData2[0])?'':$tMeData2[0];
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fList()[0];
        $tTwoData['driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tTwoData['driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow(); 
        $tTwoData['small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tTwoData['big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询一日前上午所有护理信息
        #加餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 2')->fRow();
        $tTwoData['sw_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow(); 
        $tTwoData['swsmall_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tTwoData['swbig_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tTwoData['sw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        $tTwoData['pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tTwoData['pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tTwoData['pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tTwoData['sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tTwoData['mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tTwoData['quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tTwoData['quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 1')->fList();
        $tTwoData['hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 2')->fList();
        $tTwoData['kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 3')->fList();
        $tTwoData['sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 4')->fList();
        $tTwoData['sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        if(!empty($tWCDatas)){
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tTwoData['underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tTwoData['coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tTwoData['friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tTwoData['relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];

        //查询两日前中午所有护理信息
        //胰岛素
        $tIlMO = new InsulinModel;
        $tIlData = $tIlMO->field('id')->where('sid  = '.$pId.' and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and at = 3')->fRow();
        $tTwoData['insulin'] = empty($tIlData['id'])?'':'是';
        //用饭
        $tEwData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 1')->fRow();
        $tTwoData['zw_appetite'] = empty($tEwData['appetite'])?'':$tEwData['appetite'];
        //用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-2 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-2 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        $tTwoData['zw_medicine_yi'] = empty($tMeData1[0])?'':$tMeData1[0];
        $tTwoData['zw_medicine_jj'] = empty($tMeData2[0])?'':$tMeData2[0];
        #午睡
        $tSTMO = new SiestaModel;
        $tSTData = $tSTMO->field('duration')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        $tTwoData['siesta'] = empty($tSTData['duration'])?'':$tSTData['duration']; 
        //查询两日前下午所有护理信息
        #加餐
        $tEjData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 2')->fRow();
        $tTwoData['xw_appetite'] = empty($tEjData['appetite'])?'':$tEjData['appetite'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tTwoData['xw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        $tTwoData['xw_pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tTwoData['xw_pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tTwoData['xw_pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tTwoData['xw_sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tTwoData['xw_mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tTwoData['xw_quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tTwoData['xw_quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tTwoData['xw_friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tTwoData['xw_relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];

        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 1')->fList();
        $tTwoData['xw_hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 2')->fList();
        $tTwoData['xw_kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 3')->fList();
        $tTwoData['xw_sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 4')->fList();
        $tTwoData['xw_sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        if(!empty($tWCDatas)){
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tTwoData['xw_underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tTwoData['xw_coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow(); 
        $tTwoData['xw_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tTwoData['xw_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询一日前晚上所有护理信息
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fList()[0];
        $tTwoData['ws_driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tTwoData['ws_driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #晚餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-2 days')).'\' and type = 1')->fRow();
        $tTwoData['ws_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-2 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-2 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        $tTwoData['ws_medicine_yi'] = empty($tMeData1[0])?'':$tMeData1[0];
        $tTwoData['ws_medicine_jj'] = empty($tMeData2[0])?'':$tMeData2[0];
        #夜间睡眠
        $tSlMO = new SleepModel;
        $tSlData = $tSlMO->field('status,count')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow();
        if(!empty($tSlData)){
            foreach($tSlData as $tK=>$tV){
                switch($SlData[$tK]){
                    case 1:$tSlData[$tK] = '正常';break;
                    case 2:$tSlData[$tK] = '暴动';break;
                    case 3:$tSlData[$tK] = '无睡意';break;
                }
            }
        }
        $tData['sleep_status'] = empty($tSlData['status'])?'':$tSlData['status'];
        $tTwoData['sleep_count'] = empty($tSlData['count'])?'':$tSlData['count'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-2 days')).'\'')->fRow(); 
        $tTwoData['ws_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tTwoData['ws_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];

        //查询一日前早上所有护理信息
        #血压
        $tBPData = $tBPMO->field('high_pressure,low_pressure')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        $tOneData['high_pressure'] = empty($tBPData['high_pressure'])?'':$tBPData['high_pressure'];
        $tOneData['low_pressure'] = empty($tBPData['low_pressure'])?'':$tBPData['low_pressure'];
        #血糖
        $tBSData = $tBSMO->field('blood_sugar')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        $tOneData['blood_sugar'] = empty($tBSData['blood_sugar'])?'':$tBSData['blood_sugar'];
        #体温
        $tBData = $tBMO->field('temperature')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        $tOneData['temperature'] = empty($tBData['temperature'])?'':$tBData['temperature'];
        #精神状态
        $tMData = $tMMO->field('status mood_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        $tOneData['mood_status'] = empty($tMData['mood_status'])?'':$tMData['mood_status'];
        #褥疮状态
        $tSkData = $tSkMO->field('skin_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        $tOneData['skin_status'] = empty($tSkData['skin_status'])?'':$tSkData['skin_status'];
        #洗漱
        $tNData = $tNMO->field('type nursing_type')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        if(!empty($tNData)){
        $tNData = explode(',',$tNData['nursing_type']);
        foreach($tNData as $tKey=>$tValue){
            if($tValue == 1){
                $tNData[$tKey] = '洗脸';
            }else if($tValue == 2){
                $tNData[$tKey] = '假牙清洗';
            }else if($tValue == 3){
                $tNData[$tKey] = '口腔护理';
            }
        }
        }
        $tOneData['nursing_type'] = implode(',',$tNData);
        #用饭
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 1')->fRow();
        $tOneData['appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-1 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('-1 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        $tOneData['medicine_yi'] = empty($tMeData1[0])?'':$tMeData1[0];
        $tOneData['medicine_jj'] = empty($tMeData2[0])?'':$tMeData2[0];
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fList()[0];
        $tOneData['driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tOneData['driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow(); 
        $tOneData['small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tOneData['big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询一日前上午所有护理信息
        #加餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 2')->fRow();
        $tOneData['sw_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow(); 
        $tOneData['swsmall_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tOneData['swbig_status'] = $tExData['big_status'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tOneData['sw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        $tOneData['pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tOneData['pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tOneData['pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tOneData['sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tOneData['mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tOneData['quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tOneData['quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 1')->fList();
        $tOneData['hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 2')->fList();
        $tOneData['kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 3')->fList();
        $tOneData['sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 4')->fList();
        $tOneData['sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        if(!empty($tWCDatas)){
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tOneData['underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tOneData['coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tOneData['friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tOneData['relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];

        $tVDatas = $tVMO->field('concat(relative_status) relative,concat(friend_status) friend')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fList();
        if(!empty($tVDatas)){
        $tVDatas1 = explode(',',$tVDatas[0]['relative']);
        foreach($tVDatas1 as $tK1=>$tV1){
            if($tVDatas1[$tK1] == 1){
                $tVDatas1[$tK1] = '亲人';
            }
        }
        }
        $tVDatas[0]['relative'] = empty($tVDatas1)?'':implode(',',$tVDatas1);
        $tVDatas2 = explode(',',$tVDatas[0]['friend']);
        if(!empty($tVDatas)){
        foreach($tVDatas2 as $tK2=>$tV2){
            if($tVDatas2[$tK2] == 1){
                $tVDatas2[$tK2] = '亲人';
            }
        }
        }
        $tVDatas[0]['friend'] = empty($tVDatas2)?'':implode(',',$tVDatas2);
        $tOneData['relative'] = empty($tVDatas[0]['relative'])?'':$tVDatas[0]['relative'];
        $tOneData['friend'] = empty($tVDatas[0]['friend'])?'':$tVDatas[0]['friend'];
        if(!empty($tOneData['relative']) || empty($tOneData['friend'])){
            $tOneData['visit'] = $tOneData['relative'].','.$tOneData['friend'];
        }
        //查询一日前中午所有护理信息
        //胰岛素
        $tIlMO = new InsulinModel;
        $tIlData = $tIlMO->field('id')->where('sid  = '.$pId.' and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and at = 3')->fRow();
        $tOneData['insulin'] = empty($tIlData['id'])?'':'是';
        //用饭
        $tEwData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 1')->fRow();
        $tOneData['zw_appetite'] = empty($tEwData['appetite'])?'':$tEwData['appetite'];
        //用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-1 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('-1 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        $tOneData['zw_medicine_yi'] = empty($tMeData1[0])?'':$tMeData1[0];
        $tOneData['zw_medicine_jj'] = empty($tMeData2[0])?'':$tMeData2[0];
        #午睡
        $tSTMO = new SiestaModel;
        $tSTData = $tSTMO->field('duration')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        $tOneData['siesta'] = empty($tSTData['duration'])?'':$tSTData['duration']; 
        //查询一日前下午所有护理信息
        #加餐
        $tEjData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 2')->fRow();
        $tOneData['xw_appetite'] = empty($tEjData['appetite'])?'':$tEjData['appetite'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tOneData['xw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        $tOneData['xw_pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tOneData['xw_pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tOneData['xw_pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tOneData['xw_sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tOneData['xw_mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tOneData['xw_quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tOneData['xw_quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tOneData['xw_friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tOneData['xw_relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];

        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 1')->fList();
        $tOneData['xw_hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 2')->fList();
        $tOneData['xw_kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 3')->fList();
        $tOneData['xw_sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 4')->fList();
        $tOneData['xw_sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        if(!empty($tWCDatas)){
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tOneData['xw_underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tOneData['xw_coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow(); 
        $tOneData['xw_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tOneData['xw_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询一日前晚上所有护理信息
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fList()[0];
        $tOneData['ws_driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tOneData['ws_driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #晚餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 1')->fRow();
        $tOneData['ws_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-1 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('-1 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        $tOneData['ws_medicine_yi'] = empty($tMeData1[0])?'':$tMeData1[0];
        $tOneData['ws_medicine_jj'] = empty($tMeData2[0])?'':$tMeData2[0];
        #夜间睡眠
        $tSlMO = new SleepModel;
        $tSlData = $tSlMO->field('status,count')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow();
        if(!empty($tSlData)){
            foreach($tSlData as $tK=>$tV){
                switch($SlData[$tK]){
                    case 1:$tSlData[$tK] = '正常';break;
                    case 2:$tSlData[$tK] = '暴动';break;
                    case 3:$tSlData[$tK] = '无睡意';break;
                }
            }
        }
        $tOneData['sleep_status'] = empty($tSlData['status'])?'':$tSlData['status'];
        $tOneData['sleep_count'] = empty($tSlData['count'])?'':$tSlData['count'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('-1 days')).'\'')->fRow(); 
        $tOneData['ws_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tOneData['ws_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];


        //查询今天早上所有护理信息
        #血压
        $tBPData = $tBPMO->field('high_pressure,low_pressure')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        $tData['high_pressure'] = empty($tBPData['high_pressure'])?'':$tBPData['high_pressure'];
        $tData['low_pressure'] = empty($tBPData['low_pressure'])?'':$tBPData['low_pressure'];
        #血糖
        $tBSData = $tBSMO->field('blood_sugar')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        $tData['blood_sugar'] = empty($tBSData['blood_sugar'])?'':$tBSData['blood_sugar'];
        #体温
        $tBData = $tBMO->field('temperature')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        $tData['temperature'] = empty($tBData['temperature'])?'':$tBData['temperature'];
        #精神状态
        $tMData = $tMMO->field('status mood_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        $tData['mood_status'] = empty($tMData['mood_status'])?'':$tMData['mood_status'];
        #褥疮状态
        $tSkData = $tSkMO->field('skin_status')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        $tData['skin_status'] = empty($tSkData['skin_status'])?'':$tSkData['skin_status'];
        #洗漱
        $tNData = $tNMO->field('type nursing_type')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        if(!empty($tNData)){
        $tNData = explode(',',$tNData['nursing_type']);
        foreach($tNData as $tKey=>$tValue){
            if($tValue == 1){
                $tNData[$tKey] = '洗脸';
            }else if($tValue == 2){
                $tNData[$tKey] = '假牙清洗';
            }else if($tValue == 3){
                $tNData[$tKey] = '口腔护理';
            }
        }
        }
        $tData['nursing_type'] = implode(',',$tNData);
        #用饭
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('0 days')).'\' and type = 1')->fRow();
        $tData['appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('0 days')).'\' and m.status = 1';
        $tMeData1 = $tMeMO->query($tSql);
        if(!empty($tMeData1)){
            $tStr1 = '';
            foreach($tMeData1 as $tK=>$tV){
                $tStr1 .= $tMeData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStr1)){$tStr1 = rtrim($tStr1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 1 and m.date = \''.date('Y-m-d',strtotime('0 days')).'\' and m.status = 2';
        $tMeData2 = $tMeMO->query($tSql);
        if(!empty($tMeData2)){
            $tStr2 = '';
            foreach($tMeData2 as $tK=>$tV){
                $tStr2 .= $tMeData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStr2)){$tStr2 = rtrim($tStr2,',');}
        $tData['medicine_yi'] = empty($tStr1)?'':$tStr1;
        $tData['medicine_jj'] = empty($tStr2)?'':$tStr2;
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fList()[0];
        $tData['driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tData['driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 1 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow(); 
        $tData['small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tData['big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询今天上午所有护理信息
        #加餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('0 days')).'\' and type = 2')->fRow();
        $tData['sw_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow(); 
        $tData['swsmall_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tData['swbig_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tData['sw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        $tData['pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tData['pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tData['pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tData['sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tData['mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tData['quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tData['quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('0 days')).'\' and type = 1')->fList();
        $tData['hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('0 days')).'\' and type = 2')->fList();
        $tData['kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('0 days')).'\' and type = 3')->fList();
        $tData['sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('0 days')).'\' and type = 4')->fList();
        $tData['sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        if(!empty($tWCDatas)){
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tData['underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tData['coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 2 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tData['friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tData['relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];
        //查询今天中午所有护理信息
        //胰岛素
        $tIlMO = new InsulinModel;
        $tIlData = $tIlMO->field('id')->where('sid  = '.$pId.' and date = \''.date('Y-m-d',strtotime('0 days')).'\' and at = 3')->fRow();
        $tData['insulin'] = empty($tIlData['id'])?'':'是';
        //用饭
        $tEwData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('0 days')).'\' and type = 1')->fRow();
        $tData['zw_appetite'] = empty($tEwData['appetite'])?'':$tEwData['appetite'];
        //用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('0 days')).'\' and m.status = 1';
        $tMezData1 = $tMeMO->query($tSql);
        if(!empty($tMezData1)){
            $tStrz1 = '';
            foreach($tMezData1 as $tK=>$tV){
                $tStrz1 .= $tMezData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrz1)){$tStrz1 = trim($tStrz1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 3 and m.date = \''.date('Y-m-d',strtotime('0 days')).'\' and m.status = 2';
        $tMezData2 = $tMeMO->query($tSql);
        if(!empty($tMezData2)){
            $tStrz2 = '';
            foreach($tMezData2 as $tK=>$tV){
                $tStrz2 .= $tMezData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrz2)){$tStrz2 = trim($tStrz2,',');}
        $tData['zw_medicine_yi'] = empty($tStrz1)?'':$tStrz1;
        $tData['zw_medicine_jj'] = empty($tStrz2)?'':$tStrz2;
        #午睡
        $tSTMO = new SiestaModel;
        $tSTData = $tSTMO->field('duration')->where('sid = '.$pId.' and at = 3 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        $tData['siesta'] = empty($tSTData['duration'])?'':$tSTData['duration']; 
        //查询今天下午所有护理信息
        #加餐
        $tEjData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('0 days')).'\' and type = 2')->fRow();
        $tData['xw_appetite'] = empty($tEjData['appetite'])?'':$tEjData['appetite'];
        #仪表
        $tAData = $tAMO->field('type')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        if(!empty($tAData)){
        $tAData = explode(',',$tAData['type']);
        foreach($tAData as $tKey=>$tRow){
            switch($tRow){
                case 1: $tAData[$tKey] = '理发';break;
                case 2: $tAData[$tKey] = '刮脸';break;
                case 3: $tAData[$tKey] = '剪指甲';break;
                case 4: $tAData[$tKey] = '洗头';break;
                case 5: $tAData[$tKey] = '洗澡';break;
                case 6: $tAData[$tKey] = '洗脚';break;
                case 7: $tAData[$tKey] = '修脚';break;
            }
        }
        }
        $tData['xw_appearance'] = implode(',',$tAData);
        #床铺管理
        $tBMData = $tBMMO->field('pillow_status,pillowcovers_status,pillowcase_status,sheets_status,mattess_status,quilt_status,quiltcover_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        $tData['xw_pillow_status'] = empty($tBMData['pillow_status'])?'':$tBMData['pillow_status'];
        $tData['xw_pillowcovers_status'] = empty($tBMData['pillowcovers_status'])?'':$tBMData['pillowcovers_status'];
        $tData['xw_pillowcase_status'] = empty($tBMData['pillowcase_status'])?'':$tBMData['pillowcase_status'];
        $tData['xw_sheets_status'] = empty($tBMData['sheets_status'])?'':$tBMData['sheets_status'];
        $tData['xw_mattess_status'] = empty($tBMData['mattess_status'])?'':$tBMData['mattess_status'];
        $tData['xw_quilt_status'] = empty($tBMData['quilt_status'])?'':$tBMData['quilt_status'];
        $tData['xw_quiltcover_status'] = empty($tBMData['quiltcover_status'])?'':$tBMData['quiltcover_status'];
        #探视
        $tVDatas = $tVMO->field('relative_status,friend_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fList();
        if(!empty($tVDatas)){
            foreach($tVDatas as $tK=>$tV){
                switch($tVDatas[0]['relative_status']){
                    case 1:$tVDatas[0]['relative_status'] = '亲人';break;
                    default:$tVDatas[0]['relative_status'] = '';break;
                }
                switch($tVDatas[0]['friend_status']){
                    case 1:$tVDatas[0]['friend_status'] = '朋友';break;
                    default:$tVDatas[0]['friend_status'] = '';break;
                }
            }
        }
        $tData['xw_friend'] = empty($tVDatas[0]['friend_status'])?'':$tVDatas[0]['friend_status'];
        $tData['xw_relative'] = empty($tVDatas[0]['relative_status'])?'':$tVDatas[0]['relative_status'];

        #康复干预
        $tRIDatas1 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('0 days')).'\' and type = 1')->fList();
        $tData['xw_hwx'] = empty($tRIDatas1)?'':$tRIDatas1[0]['duration'];
        $tRIDatas2 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 2')->fList();
        $tData['xw_kf'] = empty($tRIDatas2)?'':$tRIDatas2[0]['duration'];
        $tRIDatas3 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 3')->fList();
        $tData['xw_sw'] = empty($tRIDatas3)?'':$tRIDatas3[0]['duration'];
        $tRIDatas4 = $tRIMO->field('concat(duration) duration')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('-1 days')).'\' and type = 4')->fList();
        $tData['xw_sn'] = empty($tRIDatas4)?'':$tRIDatas4[0]['duration'];
        #衣物换洗
        $tWCDatas = $tWCMO->field('concat(underdress_status) underdress_status,concat(coat_status) coat_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fList();
        if(!empty($tWCDatas)){
        $tWCDatas1 = explode(',',$tWCDatas[0]['underdress_status']);
        foreach($tWCDatas1 as $tK1=>$tV1){
            if($tWCDatas1[$tK1] == 1){
                $tWCDatas1[$tK1] = '是';
            }else{
                $tWCDatas1[$tK1] = '否';
            }
        }
        }
        $tWCDatas1 = empty($tWCDatas1)?'':implode(',',$tWCDatas1);
        if(!empty($tWCDatas)){
        $tWCDatas2 = explode(',',$tWCDatas[0]['coat_status']);
        foreach($tWCDatas2 as $tK2=>$tV2){
            if($tWCDatas2[$tK2] == 1){
                $tWCDatas2[$tK2] = '是';
            }else{
                $tWCDatas2[$tK2] = '否';
            }
        }
        }
        $tWCDatas2 = empty($tWCDatas2)?'':implode(',',$tWCDatas2);
        $tData['xw_underdress'] = empty($tWCDatas1)?'':$tWCDatas1;
        $tData['xw_coat'] = empty($tWCDatas2)?'':$tWCDatas2;
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 4 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow(); 
        $tData['xw_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tData['xw_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];
        //查询今天晚上所有护理信息
        #喝水
        $tDData = $tDMO->field('sum(total) driking_total,count(id) driking_times')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fList()[0];
        $tData['ws_driking_total'] = empty($tDData['driking_total'])?'':$tDData['driking_total'];
        $tData['ws_driking_times'] = empty($tDData['driking_times'])?'':$tDData['driking_times'];
        #晚餐
        $tEData = $tEMO->field('appetite')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('0 days')).'\' and type = 1')->fRow();
        $tData['ws_appetite'] = empty($tEData['appetite'])?'':$tEData['appetite'];
        #用药
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('0 days')).'\' and m.status = 1';
        $tMewData1 = $tMeMO->query($tSql);
        if(!empty($tMeDataw1)){
            $tStrw1 = '';
            foreach($tMewData1 as $tK=>$tV){
                $tStrw1 .= $tMewData1[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrw1)){$tStrw1 = trim($tStrw1,',');}
        $tSql = 'select concat(ml.name) medicine_name from '.$tMeMO->table.' m left join '.$tMelMO->table.' ml on ml.id = m.ml_id where m.sid = '.$pId.' and m.at = 5 and m.date = \''.date('Y-m-d',strtotime('0 days')).'\' and m.status = 2';
        $tMewData2 = $tMeMO->query($tSql);
        if(!empty($tMewData2)){
            $tStrw2 = '';
            foreach($tMeDataw2 as $tK=>$tV){
                $tStrw2 .= $tMewData2[$tK]['medicine_name'].',';
            }
        }
        if(!empty($tStrw2)){$tStrw2 = trim($tStrw2,',');}
        $tData['ws_medicine_yi'] = empty($tStrw1)?'':$tStrw1;
        $tData['ws_medicine_jj'] = empty($tStrw2)?'':$tStrw2;
        #夜间睡眠
        $tSlMO = new SleepModel;
        $tSlData = $tSlMO->field('status,count')->where('sid = '.$pId.' and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow();
        if(!empty($tSlData)){
            foreach($tSlData as $tK=>$tV){
                switch($SlData[$tK]){
                    case 1:$tSlData[$tK] = '正常';break;
                    case 2:$tSlData[$tK] = '暴动';break;
                    case 3:$tSlData[$tK] = '无睡意';break;
                }
            }
        }
        $tData['sleep_status'] = empty($tSlData['status'])?'':$tSlData['status'];
        $tData['sleep_count'] = empty($tSlData['count'])?'':$tSlData['count'];
        #大便小便
        $tExData = $tExMO->field('small_status,big_status')->where('sid = '.$pId.' and at = 5 and date = \''.date('Y-m-d',strtotime('0 days')).'\'')->fRow(); 
        $tData['ws_small_status'] = empty($tExData['small_status'])?'':$tExData['small_status'];
        $tData['ws_big_status'] = empty($tExData['big_status'])?'':$tExData['big_status'];

        $this->assign('tSexData',$tSexData);
        $this->assign('tFiveData',$tFiveData);
        $this->assign('tFourData',$tFourData);
        $this->assign('tThreeData',$tThreeData);
        $this->assign('tThreeData',$tThreeData);
        $this->assign('tTwoData',$tTwoData);
        $this->assign('tOneData',$tOneData);
        $this->assign('tData',$tData);
    }
}
?>
